1. Field of the Invention
This invention relates to a portable electronic device such as a smartcard that comprises a writable or rewritable nonvolatile memory and a control device such as a CPU and performs a process according to a command from the exterior, a smartcard and a control method for the portable electronic device.
2. Description of the Related Art
Conventionally, a smartcard used as a portable electronic device comprises a data memory as a nonvolatile memory, a working memory as a volatile memory, a CPU used as a control device that accesses (data reading and/or writing) the above memories, and a program memory that stores programs or the like used for the operation of the CPU. In the above smartcard, a process of inputting or outputting data is performed based on command data supplied from an external device. Recently, the smartcards described above are used in various industrial fields.
Further, some of data items stored in the data memory of the smartcard may contain data with a TLV structure configured by an identifier that indicates a type of the data, length information indicating the length of the data and a data portion indicating the data itself. In order to access the data with the TLV structure, access can be made by using a command that specifies the identifier. For example, the smartcard retrieves data to be read by using the identifier in response to a read command received from an external device. If it is detected by the retrieval that data to be read is present, the smartcard reads data of data length indicated by length information that follows the identifier of the data to be read.
Among the data items with the TLV structure, data with a nested structure in which a plurality of child data items are stored in a data portion of parent data is provided. In the data with the nested structure, for example, a tag field or the like structured by ISO/IEC7816-4 Annex. D is defined. When access is made to data that is a part of the data with the nested structure, data to be accessed is retrieved by sequentially analyzing the data with the nested structure from the head by means of the conventional smartcard. In the above access control operation, when the size of the data with the nested structure is large or when access is frequently made to data that is a part of the data with the nested structure, it takes an excessively long time to perform the process. Particularly, recently, an application form in which massive data such as a digital signature or a public-key certificate such as e-Passport, for example, is stored in a smartcard is used in many cases. In the above application form, it is required to enhance the speed of the operation for controlling access to data that is a part of massive data.